#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc_fop_prop4.info <<'%EOF%'
   cc_fop_prop4
   ------------
   Molecule:         CO in C2v
   Wave Function:    CCS, MP2, CCSD / aug-cc-pVDZ
   Test Purpose:     First-order one-electron properties
%EOF%

#######################################################################
#  INTEGRAL INPUT
#######################################################################
cat > cc_fop_prop4.mol <<'%EOF%'
BASIS
aug-cc-pVDZ
first order property calculation on CO
dunning-basis
    2    2  X  Y  Z   1.00D-15
        6.0   1
C     0.0000000000000000  0.0000000000000000 1.21824313000000000       *
        8.0   1
O     0.0000000000000000  0.0000000000000000 -.91397310000000000       *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc_fop_prop4.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTIONS
**INTEGRAL
.DIPLEN
.THETA
.EFGCAR
.SECMOM
.DARWIN
.MASSVELO
**WAVE FUNCTION
.CC
*SCF INP
.THRESH
 1.0D-10
.DOUBLY OCCUPIED
 5 1 1 0
*CC INP
.CCS
.MP2
.CCSD
.PRINT
 4
.THRENR
1.0D-10
.THRLEQ
1.0D-07
*CCFOP
.ALLONE
**END OF DALTON INPUT
%EOF%
#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc_fop_prop4.check
cat >>cc_fop_prop4.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

# SCF, MP2 and CCSD energies:
CRIT1=`$GREP "Final * HF energy:" $log | $GREP "\-112.75469112" | wc -l`
CRIT2=`$GREP "Total SCF   energy: * \-112.75469112" $log | wc -l`
CRIT3=`$GREP "Total MP2   energy: * \-113.05873920" $log | wc -l`
CRIT4=`$GREP "Total CCSD  energy: * \-113.06527698" $log | wc -l`
TEST[1]=`expr $CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[1]=10
ERROR[1]="ENERGIES NOT CORRECT"

# RELAXED CCS FOPs:
CRIT0=`$GREP "z [ ]* ( |0)\.102216.. [ ]* ( |0)\.259808.." $log | wc -l`
CRIT1=`$GREP "1 * ( |0)\.791010.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT2=`$GREP "2 * ( |0)\.00000000 * ( |0)\.791010.. * ( |0)\.00000000" $log | wc -l`
CRIT3=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * \-1\.582021.." $log | wc -l`
CRIT4=`$GREP "1 * 7\.619823.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l` 
CRIT5=`$GREP "2 * ( |0)\.00000000 * 7\.619823.. * ( |0)\.00000000" $log | wc -l` 
CRIT6=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * 24\.789317.." $log | wc -l` 
CRIT7=`$GREP "Alfa\*\*2 Invariant:  [ ]* 178.035342" $log | wc -l` 
CRIT8=`$GREP "Beta\*\*2 Invariant:  [ ]* 294.791525" $log | wc -l` 
CRIT9=`$GREP "Isotropic Property: [ ]* 13.342988 a.u." $log | wc -l` 
CRIT10=`$GREP "Property anisotropy invariant:  [ ]* 17.169494 a.u." $log | wc -l` 
CRIT11=`$GREP "1 * ( |0)\.517994.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT12=`$GREP "2 * ( |0)\.00000000 * ( |0)\.517994.. * ( |0)\.00000000" $log | wc -l`
CRIT13=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * -1\.035989.." $log | wc -l`
CRIT14=`$GREP " O * 17 * Vx = *   0*\.259864 * \-1\.561887 * \-0*\.557966" $log | wc -l`
CRIT15=`$GREP " O * 17 * Vy = *   0*\.259864 * \-1\.561887 * \-0*\.557966" $log | wc -l`
CRIT16=`$GREP " O * 17 * Vz = * \-0*\.519728 *   3\.123773 *    1\.11593[23]" $log | wc -l`
CRIT17=`$GREP "[1-elec.]* Darwin term: * ( |0)\.260552" $log | wc -l`
CRIT18=`$GREP "Mass-Velocity term: *   ( -|-0)\.327183" $log | wc -l`
CRIT19=`$GREP "(Mass-Velocity \+ 1\-elec. Darwin terms|Total relativistic correction):[ ]* ( -|-0)\.066631" $log | wc -l`
TEST[2]=`expr $CRIT0  \+ $CRIT1  \+ $CRIT2  \+ $CRIT3  \+ $CRIT4 \+ \
              $CRIT5  \+ $CRIT6  \+ $CRIT7  \+ $CRIT8  \+ $CRIT9 \+ \
              $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ $CRIT13 + $CRIT14 \+ \
              $CRIT15 \+ $CRIT16 + $CRIT17 \+ $CRIT18 \+ $CRIT19`
CTRL[2]=20
ERROR[2]="RELAXED CCS FIRST-ORDER PROPERTIES NOT CORRECT"

# RELAXED MP2 FOPs:
CRIT0=`$GREP "z [ ]* ( -|-0)\.116570.. [ ]* ( -|-0)\.296293.." $log | wc -l`
CRIT1=`$GREP "1 * ( |0)\.785471.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT2=`$GREP "2 * ( |0)\.00000000 * ( |0)\.785471.. * ( |0)\.00000000" $log | wc -l`
CRIT3=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * \-1\.570942.." $log | wc -l`
CRIT4=`$GREP "1 * 7\.765206.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l` 
CRIT5=`$GREP "2 * ( |0)\.00000000 * 7\.765206.. * ( |0)\.00000000" $log | wc -l` 
CRIT6=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * 24\.923621.." $log | wc -l` 
CRIT7=`$GREP "Alfa\*\*2 Invariant:  [ ]* 181.836552" $log | wc -l` 
CRIT8=`$GREP "Beta\*\*2 Invariant:  [ ]* 294.411214" $log | wc -l` 
CRIT9=`$GREP "Isotropic Property: [ ]* 13.484678 a.u." $log | wc -l` 
CRIT10=`$GREP "Property anisotropy invariant:  [ ]* 17.158415 a.u." $log | wc -l` 
CRIT11=`$GREP "1 * ( |0)\.400699.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT12=`$GREP "2 * ( |0)\.00000000 * ( |0)\.400699.. * ( |0)\.00000000" $log | wc -l`
CRIT13=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * ( -|-0)\.801399.." $log | wc -l`
CRIT14=`$GREP " O [ ]* 17    Vx =       ( |0)\.301058    \-1\.809479    ( -|-0)\.646416" $log | wc -l`
CRIT15=`$GREP " O [ ]* 17    Vy =       ( |0)\.301058    \-1\.809479    ( -|-0)\.646416" $log | wc -l`
CRIT16=`$GREP " O [ ]* 17    Vz =      ( -|-0)\.602116     3\.618957     1\.292831" $log | wc -l`
CRIT17=`$GREP "[1-elec.]* Darwin term: [ ]* ( |0)\.260493" $log | wc -l`
CRIT18=`$GREP "Mass-Velocity term: [ ]*( -|-0)\.327191" $log | wc -l`
CRIT19=`$GREP "(Mass-Velocity \+ 1\-elec. Darwin terms|Total relativistic correction):[ ]* ( -|-0)\.066698" $log | wc -l`
TEST[3]=`expr $CRIT0  \+ $CRIT1  \+ $CRIT2  \+ $CRIT3  \+ $CRIT4 \+ \
              $CRIT5  \+ $CRIT6  \+ $CRIT7  \+ $CRIT8  \+ $CRIT9 \+ \
              $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ $CRIT13 + $CRIT14 \+ \
              $CRIT15 \+ $CRIT16 + $CRIT17 \+ $CRIT18 \+ $CRIT19`
CTRL[3]=20
ERROR[3]="RELAXED MP2 FIRST-ORDER PROPERTIES NOT CORRECT"


# RELAXED CCSD FOPs:
CRIT0=`$GREP "z [ ]* ( -|-0)\.038187.. [ ]* ( -|-0)\.097063.." $log | wc -l`
CRIT1=`$GREP "1 * ( |0)\.767386.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT2=`$GREP "2 * ( |0)\.00000000 * ( |0)\.767386.. * ( |0)\.00000000" $log | wc -l`
CRIT3=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * \-1\.534772.." $log | wc -l`
CRIT4=`$GREP "1 * 7\.724067.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l` 
CRIT5=`$GREP "2 * ( |0)\.00000000 * 7\.724067.. * ( |0)\.00000000" $log | wc -l` 
CRIT6=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * 24\.846312.." $log | wc -l` 
CRIT7=`$GREP "Alfa\*\*2 Invariant:  [ ]* 180.404714" $log | wc -l` 
CRIT8=`$GREP "Beta\*\*2 Invariant:  [ ]* 293.171292" $log | wc -l` 
CRIT9=`$GREP "Isotropic Property: [ ]* 13.431482 a.u." $log | wc -l` 
CRIT10=`$GREP "Property anisotropy invariant:  [ ]* 17.122246 a.u." $log | wc -l` 
CRIT11=`$GREP "1 * ( |0)\.422751.. * ( |0)\.00000000 * ( |0)\.00000000" $log | wc -l`
CRIT12=`$GREP "2 * ( |0)\.00000000 * ( |0)\.422751.. * ( |0)\.00000000" $log | wc -l`
CRIT13=`$GREP "3 * ( |0)\.00000000 * ( |0)\.00000000 * ( -|-0)\.845502.." $log | wc -l`
CRIT14=`$GREP " O [ ]* 17    Vx =       ( |0)\.274739    \-1\.651291    ( -|-0)\.589905" $log | wc -l`
CRIT15=`$GREP " O [ ]* 17    Vy =       ( |0)\.274739    \-1\.651291    ( -|-0)\.589905" $log | wc -l`
CRIT16=`$GREP " O [ ]* 17    Vz =      ( -|-0)\.549478     3\.302583     1\.179810" $log | wc -l`
CRIT17=`$GREP "[1-elec.]* Darwin term: [ ]* ( |0)\.260465" $log | wc -l`
CRIT18=`$GREP "Mass-Velocity term: [ ]*( -|-0)\.327136" $log | wc -l`
CRIT19=`$GREP "(Mass-Velocity \+ 1\-elec. Darwin terms|Total relativistic correction):[ ]* ( -|-0)\.066670" $log | wc -l`
TEST[4]=`expr $CRIT0  \+ $CRIT1  \+ $CRIT2  \+ $CRIT3  \+ $CRIT4 \+ \
              $CRIT5  \+ $CRIT6  \+ $CRIT7  \+ $CRIT8  \+ $CRIT9 \+ \
              $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ $CRIT13 + $CRIT14 \+ \
              $CRIT15 \+ $CRIT16 + $CRIT17 \+ $CRIT18 \+ $CRIT19`
CTRL[4]=20
ERROR[4]="RELAXED CCSD FIRST-ORDER PROPERTIES NOT CORRECT"


PASSED=1
for i in 1 2 3 4 
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi                
%EOF%
#######################################################################
